﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HardToolApp.Model
{
    public enum iic_addr_len
    {
        IIC_ADDR_LEN_7 = 0,
        IIC_ADDR_LEN_10
    }
    public class IICMasterModel: Communicate
    {
        
        private iic_addr_len _addrLen;
        public iic_addr_len addrLen {  get { return _addrLen; } set { SetProperty(ref _addrLen, value); } }
        private UInt16 _timeout = 1000;
        public UInt16 timeout { get { return _timeout; }set { SetProperty(ref _timeout, value); } }
        private int _clock = 100;
        public int clock { get { return _clock; } set { SetProperty(ref _clock, value); } }

        public int readBytesLen { get; set; } = 4;
        public byte readAddr = 0xa0;
        private string _readAddrStr;
        public string readAddrStr
        {
            get { return readAddr.ToString("X2"); }
            set { SetProperty(ref _readAddrStr, value); readAddr = Convert.ToByte(_readAddrStr, 16); }
        }

        public IICMasterModel() : base(CommCmd.COMM_IIC_MASTER) { }

        public override string ToString()
        {
            switch (subCmd)
            {
                case 1:
                    return "改变IIC主机参数->时钟频率:" + clock.ToString() + "\n";
                case 2:
                    return "IIC主机写入数据->" + sendBytes + "\n";
                case 3:
                    return "IIC主机读取"+ readBytesLen.ToString()+"个数据" + "\n";
                default:
                    return "未知命令" + "\n";
            }
        }

    }
}
